Repository navigation
Conversation
There was a problem hiding this comment.
Just a couple of comma NITS ... "Because" is considered to always (well, usually 😄) introduce essential information. As an essential clause, it doesn't receive a leading comma.
Note tho in passing that "because" could introduce non-essential info. Usually tho, the author intends the clause to make the meaning of the rest of the sentence clear. In these cases on the PR, it looks like it's important to understand why the behavior is occurring ... that the sentence is meant to explain the reasoning to the reader. Feel free to push back if that isn't the case. I'll approve if you want to treat these clauses as non-essential.
There was a problem hiding this comment.
🟢 Approval recommended
The review reports no active issues with the return-URL hardening and documentation updates.
No open issues 🎉
What changed in this PR
Addresses #38217 by hardening return-URL handling in ASP.NET Core authentication documentation and samples, and extending open-redirect guidance to Blazor.
Changes:
- Validates OIDC return URLs with
Url.IsLocalUrl, falling back to the app root. - Restricts the Blazor Identity login component’s return navigation to validated URLs within the app.
- Adds Blazor guidance for safe navigation and links, and closes an unterminated code block.
| File | Description |
|---|---|
aspnetcore/security/preventing-open-redirects.md |
Adds Blazor return-URL validation guidance and fixes the code fence. |
aspnetcore/security/authentication/configure-oidc-web-authentication/samples/oidc-net8/RazorPageOidc/Pages/Login.cshtml.cs |
Validates return URLs before starting the OIDC challenge. |
aspnetcore/security/authentication/configure-oidc-web-authentication.md |
Updates the inline OIDC example to match the safer sample. |
aspnetcore/blazor/security/webassembly/standalone-with-identity/qrcodes-for-authenticator-apps.md |
Validates return destinations in the inline Blazor login component. |
Review effort: Balanced
|
@guardrex Thank you. I'll wait for agreement on the recommended code shape in the review of the project template change in dotnet/aspnetcore. Then I will use that in all places where we show a similar code (templates, samples, docs, scaffolding). |
Two articles show return URL handling that allows open redirects, and the open redirect guidance doesn't cover Blazor.
The Blazor code matches the recommended code merged in dotnet/aspnetcore#70796.
Changes:
configure-oidc-web-authentication.mdand theRazorPageOidcsample: theLoginpage passedReturnUrl=//evil.examplethrough and reducedhttps://host//evil.exampleto//evil.example. It now usesUrl.IsLocalUrland falls back to the app root.qrcodes-for-authenticator-apps.md: the inlineLogincomponent navigated toReturnUrlwithout checking it, which also allowedjavascript:URLs. It now matches the fixed sample in Validate return URLs in Blazor samples blazor-samples#693.preventing-open-redirects.md: new section on validating return URLs in Blazor apps, both for navigation and for links. It also adds a missing closing fence to the previous code block, which would otherwise swallow the new section.Validation: the
RazorPageOidcsample builds, and the examples in the new section were checked with a small test program.Fixes #38217
Internal previews
Build report